function [best_lower_bounds, best_upper_bounds, PICP, PINAW, AIS] = kdePI(test_ori, test_pre, train_error, E, alpha)

    n_train = length(train_error);
    std_dev_train = std(train_error);
    bandwidth_train = E* std_dev_train * n_train^(-1/5);
    
    [f_train, x_train] = ksdensity(train_error, 'Kernel', 'normal','Function','pdf', 'Bandwidth', bandwidth_train);
    
    % 计算累积分布函数（CDF）
    cdf_train = cumsum(f_train) * (x_train(2) - x_train(1));
    
    % 计算测试集的下界和上界85
    lower_bounds_train = zeros(size(test_pre));
    upper_bounds_train = zeros(size(test_pre));
    for i = 1:numel(test_pre)
        lower_bounds_train(i) = test_pre(i) + interp1(cdf_train, x_train, alpha/2);
        upper_bounds_train(i) = test_pre(i) + interp1(cdf_train, x_train, (1-alpha/2));
    end
    % 显示测试集的最终区间估计结果
    
    best_lower_bounds = lower_bounds_train;
    best_upper_bounds = upper_bounds_train;
    % best_lower_bounds(best_lower_bounds<0) = 0;
    % best_upper_bounds(best_upper_bounds<0) = 0;

    % 计算最终的区间估计
    PICP = calc_PICP(test_ori, best_lower_bounds, best_upper_bounds);
    PINAW = calc_PINAW(test_ori, best_lower_bounds, best_upper_bounds);
    % 显示测试集的 PICP 和 PINAW 的结果
    fprintf('%d%%PICP: %.2f%%\n', (1-alpha)*100, PICP*100);
    fprintf('%d%%PINAW: %.4f\n', (1-alpha)*100, PINAW);

    % CWC = calc_CWC(PINAW,PICP,alpha,0.8);
    % fprintf('%d%%CWC: %.4f\n', (1-alpha)*100, CWC);

    AIS = calc_AIS(test_ori, best_lower_bounds, best_upper_bounds, alpha);
    fprintf('%d%%AIS: %.4f\n', (1-alpha)*100, AIS);
end